package WebService

import (
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	"github.com/go-playground/validator/v10"
	"wskyygyso/casually/Services"
	"wskyygyso/casually/Validator"
)

var WebService *gin.Engine

func init() {
	WebService = gin.Default()
}

func collect() {
	if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
		v.RegisterValidation("IdExists", Validator.IdExists)
	}
	commentTerms := new(Services.CommentTermsBannedService)
	WebService.Handle("GET", "/commentTermsBanned", commentTerms.List)
	WebService.Handle("GET", "/commentTermsBanned/:id", commentTerms.Show)
	WebService.Handle("DELETE", "/commentTermsBanned/:id", commentTerms.Delete)
	WebService.Handle("POST", "/commentTermsBanned", commentTerms.Store)
}

func Run(port string) {
	collect()
	WebService.Run(port)
}
